Package edu.uky.ai.ml.nn
Class NeuralNetwork
java.lang.Object
edu.uky.ai.ml.nn.NeuralNetwork
public class NeuralNetwork
extends java.lang.Object
A neural network is a computational model, based roughly on biological
networks of neurons, which can be trained to perform well on various
kinds of classification and non-linear regression tasks. This particular
implementation is a feed-forward network with 0 or more hidden layers.
- Author:
- Stephen G. Ware
-
Field Summary
-
Constructor Summary
Constructors Constructor Description NeuralNetwork(int input, int output, int hiddenLayers, int hiddenNodes, java.util.Random random)Constructs a new neural network of a given size. -
Method Summary
Modifier and Type Method Description java.lang.Stringclassify(Database database, double[] input)Given a database of examples and a set of values for the input neurons, this method calculates the output of the network and returns the class label of the training example whose output is most similar to the network's output.doublegetAccuracy(Database database)Quantifies how will this network performs on a given database of training examples.doublegetError(Database database)Returns the total error of the network for a given training database.double[]getOutput()Calculates and returns the values of the output neurons given the current state of the network.voidsetInput(double[] values)Sets the input neurons to the given values.
-
Field Details
-
Constructor Details
-
NeuralNetwork
public NeuralNetwork(int input, int output, int hiddenLayers, int hiddenNodes, java.util.Random random)Constructs a new neural network of a given size.- Parameters:
input- the number of input neuronsoutput- the number of output neuronshiddenLayers- the number of hidden layershiddenNodes- the number of neurons per hidden layerrandom- a random number generator for setting the initial edge weights
-
-
Method Details
-
setInput
public void setInput(double[] values)Sets the input neurons to the given values.- Parameters:
values- the values
-
getOutput
public double[] getOutput()Calculates and returns the values of the output neurons given the current state of the network.- Returns:
- the values of all output neurons
-
getError
Returns the total error of the network for a given training database. The total error is simply the sum of all errors on the training examples.- Parameters:
database- the training database- Returns:
- the total error
-
classify
Given a database of examples and a set of values for the input neurons, this method calculates the output of the network and returns the class label of the training example whose output is most similar to the network's output.- Parameters:
database- the training databaseinput- the values for the input neurons- Returns:
- the class label of the example most similar to the network output
-
getAccuracy
Quantifies how will this network performs on a given database of training examples. Accuracy is simple the number of correctly classified examples divided by the total number of examples.- Parameters:
database- the database of examples- Returns:
- the accuracy
-